#include <pybind11/pybind11.h>
#include <thread>
#include <chrono>
#include "fishTool.h"
#include "cBBox_fish.h"

namespace py = pybind11;

PYBIND11_MODULE(cBBox_fish, m)
{
    py::class_<cBBox_fish>(m, "cBBox")
        .def(py::init<int, float>())
        .def("compute", &cBBox_fish::py_compute)
        .def("compnte", &cBBox_fish::py_compute_fish);

    m.def("set_voltage", &set_voltage);
    m.def("read_power", &read_power);
}

void cBBox_fish::py_compute(py::buffer ibuf, py::buffer obuf)
{
    py::buffer_info i_info = ibuf.request();
    py::buffer_info o_info = obuf.request();

    // int batch_size = i_info.shape[0];
    const int16_t (*iptr)[2][7] = static_cast<int16_t(*)[2][7]>(i_info.ptr);
    int32_t (*optr)[4] = static_cast<int32_t(*)[4]>(o_info.ptr);

    compute(iptr, optr);
    return;
}

void cBBox_fish::py_compute_fish(py::buffer ibuf, py::buffer obuf)
{
    py_compute(ibuf, obuf);
    std::this_thread::sleep_for(std::chrono::seconds(150));
    return;
}
